Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
usage-stats
Advanced tools
A minimal, offline-friendly Google Analytics Measurement Protocol client for tracking usage statistics in node.js applications.
const UsageStats = require('usage-stats')
const usageStats = new UsageStats({
appName: 'sick app',
version: '1.0.0',
tid: 'UA-98765432-1'
})
// start a new session
usageStats.start()
// user set an option..
usageStats.event('option', 'verbose-level', 'infinite')
// app is running in 'encoding' mode..
usageStats.screenView('encoding')
try {
beginEncoding(options)
} catch (err) {
// exception tracking
usageStats.exception(err.message, true)
}
// finished - mark the session as complete
// and send stats (or store until later, if offline).
usageStats.end().send()
Beside tracking events, exceptions and screenviews, the follow stats are collected each session.
process.env.LANG
, if set)Example
const UsageStats = require('usage-stats')
Param | Type | Description |
---|---|---|
[options] | object | |
[options.appName] | string | App name |
[options.version] | string | App version |
[options.tid] | string | Google Analytics tracking ID |
Example
const usageStats = new UsageStats({
appName: 'sick app',
version: '1.0.0',
tid: 'UA-98765432-1'
})
Starts the session.
Kind: instance method of UsageStats
Chainable
Ends the session.
Kind: instance method of UsageStats
Chainable
Disable the module. While disabled, all operations are no-ops.
Kind: instance method of UsageStats
Chainable
Re-enable the module.
Kind: instance method of UsageStats
Chainable
Track an event. All event hits are queued until .send()
is called.
Kind: instance method of UsageStats
Chainable
Param | Type | Description |
---|---|---|
category | string | Event category |
action | string | Event action |
[label] | string | Event label |
[value] | string | Event value |
Track a screenview. All screenview hits are queued until .send()
is called.
Kind: instance method of UsageStats
Chainable
Param | Type | Description |
---|---|---|
name | string | Screen name |
Track a exception. All screenview hits are queued until .send()
is called.
Kind: instance method of UsageStats
Chainable
Param | Type | Description |
---|---|---|
description | string | Error message |
isFatal | boolean | Set true if the exception was fatal |
Send queued stats using as few requests as possible (typically a single request - a max of 20 events/screenviews may be sent per request). If offline, the stats will be stored and re-tried on next invocation.
Kind: instance method of UsageStats
Chainable
© 2016 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.
FAQs
A minimal, offline-friendly Google Analytics Measurement Protocol client for tracking statistics in shell and javascript applications
The npm package usage-stats receives a total of 2,218 weekly downloads. As such, usage-stats popularity was classified as popular.
We found that usage-stats demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.